<?php
/** costumer_table.php
 * Project name: project_name
 * Created on: 15.12.2011
 * Author: Matias Thomsen
 * 
 * Tabelarische darstellung einer Liste von Customers
 */

    ?>
<?php if ( is_array($customers) ){  ?>
<div class="clear"></div>
<div>
            <table id="js_table_layout" style="width: 100%">
                    <thead>
                            <tr>
                                    <th style="width: 15%;text-align: left; text-indent: 5px;">KundenNr.</th>
                                    <th style="width: 8%; text-align: left; text-indent: 5px;">Anrede</th>
                                    <th style="width: 15%; text-align: left; text-indent: 5px;">Nachname</th>
                                    <th style="width: 20%; text-align: left; text-indent: 5px;">Vorname</th>
                                    <th style="width: 6%; text-align: left; text-indent: 5px;">Geburtsdatum</th>
                                    <th style="width: 11%; text-align: left; text-indent: 5px;">&nbsp;</th>
                            </tr>
                    </thead>
                    <tbody>
    <?php
    
    foreach ( $customers as $customer_row ){
        if ( $customer_row->getInBearbeitung() === null ){
            $inBearbeitung = "&ib=0";
            
        }else{
            $inBearbeitung = "&ib=1";
        }
    ?>
                            <tr>
                                    <td style="text-indent: 10px;"><?= $customer_row->getKundenNr() ?></td>
                                    <td style="text-indent: 10px;"><?= $customer_row->getAnrede() ?></td>
                                    <td style="text-indent: 10px;"><?= $customer_row->getNachname() ?></td>
                                    <td style="text-indent: 10px;"><?= $customer_row->getName() ?></td>
                                    <td style="text-align: center;"><?= $customer_row->getGeburtsdatum() ?></td>
                                    <td style="text-align: center;">
                                            <?php if ( in_array("view", $action) ){ ?>
                                                    <a href="?page=customer-view&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Details</a>
                                                    
                                            <?php } if ( in_array("zentrale", $action) ){ ?>
                                                    <a href="?page=supervisor-zentrale&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Details</a>

                                            <?php } if ( in_array("bezirk", $action) ){ ?>
                                                    <a href="?page=supervisor-bezirk&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Details</a>        
                                            
                                            <?php } if ( in_array("filiale", $action) ){ ?>
                                                    <a href="?page=supervisor-filiale&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Details</a>
                                                    
                                            <?php } if ( in_array("enable", $action) ){ ?>
                                                    <a href="?page=customer-enable&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Freigeben</a>
                                                    
                                            <?php } if ( in_array("edit", $action) ){ ?>
                                                    <a href="?page=customer-edit&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?>">Bearbeiten</a>
                                            <?php } if ( in_array("transfer", $action) ){
                                                if ( isset($_GET['neue-stelle']) ){
                                                    $get = "&neue-stelle=".$_GET['neue-stelle'];
                                                }else{
                                                    $get = "";
                                                }
                                            ?>
                                                    <a href="?page=customer-transfer&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung ?><?= $get ?>">Transfer</a>
                                                    
                                            <?php } if ( in_array("delete", $action) ){
                                                if ( isset($_GET['action']) ){
                                                    $get = "&action=".$_GET['action'];
                                                }else{
                                                    $get = "";
                                                }
                                            ?>
                                            <a href="?page=customer-delete&kunden-nr=<?= $customer_row->getKundenNr().$inBearbeitung.$get ?>">Löschen</a>
                                            <?php } ?>
                                    </td>
                            </tr>
    <?php
    }
    ?>
                    </tbody>
            </table>
</div>
<script lang="JavaScript">
        $(document).ready(function() {
            $('#js_table_layout').dataTable();
//            $('#js_table_layout').flexigrid({height:'auto',striped:false});

        } );
</script>
<?php
} //end if ( count($customers) > 0 ){
else{
?>
<div class="display-errors-label">
    <p>Es sind keine Einträge für diesem Bereich vorhanden</p>
</div>
<?php
}
?>